Date.prototype.toLocaleDateString = function() {
	return this.getFullYear() + "/" + (this.getMonth() + 1) + "/" + this.getDate();
};
Date.prototype.toLocaleString = function() {
	return this.toLocaleDateString() + ", " + this.toLocaleTimeString();
};
/**
 * view helper 助手
 */
module.exports = function(req, res, next) {

	/**
	 * 时间格式化
	 * @param  int unix unix 时间戳（秒）
	 */
	res.locals.dateFormat = function(unix) {
		var time_int = parseInt(unix);
		if (isFinite(time_int)) {
			var now = new Date(time_int);
		} else {
			now = new Date;
		}
		return now.toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
	}

	res.locals.spaceX = function(x) {
		var space = "";
		for (var i = 0; i < x; i++) {
			space += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
		}
		return space;
	}

	next();
};